#include "Solution.h"
#include <iostream>

using namespace std;

int main()
{
	int n;
	Solution s;
	while(cin>>n)
	{
		if(n==0)
			break;

		int rc = s.reverse(n);
		cout<<rc<<endl;
	}
}